home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0897.zip
/
CCDBMS.ZIP
/
DBASE.H
< prev
next >
Wrap
C/C++ Source or Header
|
1997-03-18
|
2KB
|
82 lines
// =================================================================
// Dbase.h
// =================================================================
// Harold Kasperink / John Dekker
// Dr. Dobb's Journal 1997
// =================================================================
// Dbase command class
// =================================================================
#ifndef _DBASE_H_
#define _DBASE_H_
#include <string.h>
#include "thread.h"
#include "mutex.h"
#include "dbcmd.h"
class CArrayDbase;
////////////////////////////////////////////////////////////////////
// CDbase
////////////////////////////////////////////////////////////////////
class CDbase : public CThread
{
private:
friend class CArrayDbase;
// Lockes usage of object
CMutex m_mtxInuse;
// Instruct dbase-thread to do command
CMutex m_mtxStartSql;
// Informs instruct-thread command is done
CMutex m_mtxEndSql;
// Make sure no parallel usage of do
CMutex m_mtxDoCmd;
// User name
char* m_pszUsr;
// User password
char* m_pszPsswd;
// Database connect string
char* m_pszDb;
// boolean flag indicates if connected
boolean m_bConnected;
// Continue flag
boolean m_bContinue;
// Current command
CDbCommand* m_pCommand;
// Return code of command execution
long m_lSql;
public:
CDbase();
virtual ~CDbase();
// Command functions
long Do(CDbCommand &command);
// Commit
void Commit(boolean bUnlock=TRUE);
// Rollback
void Rollback(boolean bUnlock=TRUE);
private:
// Thread loop overwrite
virtual void Process();
// Inuse Funtions
boolean TryLock();
void Lock();
void Unlock();
// Connect functions
void ConnectInfo(const char *szUsr, const char *szPasswd, const char *szDB);
void DeleteConnectInfo();
long Connect();
void Disconnect();
};
#endif